﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<script src="~/lib/layui/layui.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">转移单编号</label>
            <div class="layui-input-inline">
                <input type="text" name="input1" placeholder="请输入" autocomplete="off" class="layui-input" id="TransferOrderNumber">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">转移单名称</label>
            <div class="layui-input-inline">
                <input type="text" name="input2" placeholder="请输入" autocomplete="off" class="layui-input" id="TransferOrderName">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">转移单类型</label>
            <div class="layui-input-inline">
                <div class="layui-form layui-row layui-col-space16">
                    <div class="layui-col-md6" id="isType">
                        <select id="isTypes">
                            <option value="">请选择</option>
                            <option value="0">内部转移</option>
                            <option value="1">外部转移</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">移除仓库</label>
                <div class="layui-input-inline">
                    <div class="layui-form layui-row layui-col-space16">
                        <div class="layui-col-md6" id="StashId">
                            <select id="city">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">移入仓库</label>
                <div class="layui-input-inline">
                    <div class="layui-form layui-row layui-col-space16">
                        <div class="layui-col-md6" id="StashIds">
                            <select id="gh">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-btn-container">
            <button type="button" class="layui-btn layui-btn-warm layui-btn-radius" lay-on="test-iframe-curl">新增</button>
            <button type="button" class="layui-btn " onclick="StashHtml()">查询</button>
        </div>
        <div>
            <table class="layui-hide" id="ID-table-demo-data"></table>
        </div>
    </div>
    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
    <script>

        //就绪函数
        $(function () {


            StashHtml()
            Stash()
        })
        //仓库显示
        function Stash() {

            var stashNum = "";
            var stashName = "";

            $.ajax({

                url: '@ViewBag.FoundationRead'+ '/api/Acquire/StashHtml',
                data: JSON.stringify({ stashNum: stashNum, stashName: stashName }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    $(res.data).each(function (i, item) {
                        $('#city').append(`<option value="` + item.stashId + `">` + item.stashName + `</option>`);
                    })
                    $(res.data).each(function (i, item) {
                        $('#gh').append(`<option value="` + item.stashId + `">` + item.stashName + `</option>`);
                    })
                    layui.form.render("select");
                }
            })
        }




        function StashHtml() {


            var TransferOrderNumber = $("#TransferOrderNumber").val();
            var TransferOrderName = $("#TransferOrderName").val();
            var isType = $("#isTypes").val() == "" ? -1 : $("#isTypes").val();
            var StashId = $("#city").val() == "" ? 0 : $("#city").val();
            var StashIds = $("#gh").val() == "" ? 0 : $("#gh").val();


            $.ajax({

                url: '@ViewBag.FoundationRead'+ '/api/Production/TransferHtmls',
                data: JSON.stringify({ TransferOrderNumber: TransferOrderNumber, TransferOrderName: TransferOrderName, isType: isType, StashId: StashId, StashIds: StashIds }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {

                    console.log(res.data)
                    layui.use('table', function () {
                        var table = layui.table;

                        // 已知数据渲染
                        var inst = table.render({
                            elem: '#ID-table-demo-data',
                            toolbar: '#toolbarDemo',
                            cols: [[ //标题栏
                                { field: 'transferOrderNumber', title: '转移挑拨单编号', width: 200, sort: true },
                                { field: 'transferOrderName', title: '转移挑拨单名称', width: 200 },
                                { field: 'stasTypename', title: '转移挑拨单类型', width: 200 },
                                { field: 'stashdName', title: '移除仓库', width: 200 },
                                { field: 'stashName', title: '移入仓库', width: 200 },
                                { field: 'transfertime', title: '转移日期', width: 200 },
                                { field: 'infoMess', title: '单据状态', width: 200 },
                            ]],
                            data: res.data,
                            //skin: 'line', // 表格风格
                            //even: true,
                            page: true, // 是否显示分页
                            limits: [5, 10, 15],
                            limit: 5 // 每页默认显示的数量
                        });
                    });
                }

            })
        }

        var $ = layui.$;
        var layer = layui.layer;
        var util = layui.util;
        // 事件
        util.on('lay-on', {

            'test-iframe-curl': function () {
                layer.open({
                    type: 2,
                    title: '转移挑拨单',
                    shadeClose: true,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['900px', '600px'],
                    content: '/Document/DiversionAdd'
                });
            }
        })

        // 事件





    </script>

</body>
</html>